42a57d99-zLxBjzC7rfj_perV-orUg tools/xenstore/xenstored_watch.h
42a57d99BnkhISKgCCRcUqhteyuxCw tools/xenstore/xs.c
42a57d99FyiYSz9AkKKROrRydnA-gQ tools/xenstore/xs.h
+42b29922EYQ87Y4fwZXSkEHgtQk7CQ tools/xenstore/xs_dom0_test.c
42a57d99SrtsJCDUlKyRPf3EX86A1Q tools/xenstore/xs_lib.c
42a57d99L2pYeMFyjQ_4Rnb17xTSMg tools/xenstore/xs_lib.h
42a57d99Kl6Ba8oCHv2fggl7QN9QZA tools/xenstore/xs_random.c
all: xen xenstored libxenstore.a libxenstore-pic.a
-testcode: xen xs_test xenstored_test xs_random
+testcode: xen xs_test xenstored_test xs_random xs_dom0_test
xen:
ln -sf $(XEN_ROOT)/xen/include/public $@
libxenstore-pic.a: $(LIB_OBJS_PIC)
clean: testsuite-clean
- rm -f *.o *.opic *.a
- rm -f xs_test xenstored xenstored_test xs_random xs_stress xen
+ rm -f *.o *.opic *.a xen
+ rm -f xs_test xenstored xenstored_test xs_random xs_stress xs_dom0_test
-$(RM) $(PROG_DEP)
check: testsuite-run randomcheck stresstest
rm -rf $(TESTDIR)/store
export $(TESTENV); PID=`./xenstored_test --output-pid`; ./xs_stress 10000; ret=$$?; kill $$PID; exit $$ret
+xs_dom0_test: xs_dom0_test.o utils.o
+ $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -lxc -o $@
+
TAGS:
etags `find . -name '*.[ch]'`
--- /dev/null
+/* Test introduction of domain 0 */
+#include <linux/ioctl.h>
+#include <sys/ioctl.h>
+#include "xs.h"
+#include "utils.h"
+#include <xc.h>
+#include <xen/linux/privcmd.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/mman.h>
+
+int main()
+{
+ int h, local = 0, kernel = 0;
+ long err;
+ void *page;
+
+ h = xc_interface_open();
+ if (h < 0)
+ barf_perror("Failed to open xc");
+
+ if (xc_evtchn_bind_interdomain(h, DOMID_SELF, 0, &local, &kernel) != 0)
+ barf_perror("Failed to bind interdomain");
+
+ printf("Got ports %i & %i\n", local, kernel);
+
+ err = ioctl(h, IOCTL_PRIVCMD_INITDOMAIN_STORE, kernel);
+ if (err < 0)
+ barf_perror("Failed to initialize store");
+ printf("Got mfn %li\n", err);
+
+ page = xc_map_foreign_range(h, 0, getpagesize(), PROT_READ|PROT_WRITE,
+ err);
+ if (!page)
+ barf_perror("Failed to map page %li", err);
+ printf("Mapped page at %p\n", page);
+ printf("Page says %s\n", (char *)page);
+ munmap(page, getpagesize());
+ printf("unmapped\n");
+
+ return 0;
+}
+